<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue'
// 返回顶部按钮
const isFixed = ref(false)
const fixedOffest = 64
const handleScroll = () => {
  isFixed.value = window.scrollY > fixedOffest
}
onMounted(() => {
  window.addEventListener('scroll', handleScroll)
})
onUnmounted(() => {
  window.removeEventListener('scroll', handleScroll)
})
</script>

<template>
  <!-- 二级路由出口及展示位置 -->
  <div class="content-placeholder" v-if="isFixed"></div> <!-- 占位元素，防止导航栏固定后内容跳动 -->
  <nav :class="{ 'fixed-nav': isFixed }">
    <div>
      <a href="#">
        <img src="/images/ordinaryPicture/islideLogo.png" class="leftPhoto">
      </a>
    </div>
    <div class="navCenter">
      <ul router>
        <li class="homeTemp Temp"><router-link to="/HomePage">
            <div class="nav-indicator"></div>
            <div class="theFirst">首页</div>
            <div class="theSecond">首页</div>
          </router-link></li>
        <li class="pptTemp Temp"><router-link to="/PptTemplate">
            <div class="nav-indicator special"></div>
            <div class="theFirst">PPT模板</div>
            <div class="theSecond">PPT模板</div>
            <img src="/images/ordinaryPicture/freeGeneration.png" class="free">
          </router-link>
          <div class="PPTBox all">
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/mould.png">
              </div>
              <div class="text">
                <p>模板广场</p>
                <span>海量优质的演示模板素材</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/hot.png">
              </div>
              <div class="text">
                <p>热门专题</p>
                <span>每月定期更新编辑精选资源</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/beta.png">
              </div>
              <div class="text">
                <p>AI 模板</p>
                <span>一句话智能创建 PPT</span>
              </div>
            </a>
          </div>
        </li>
        <li class="functionTemp Temp"><router-link to="/FuctionGlace">
            <div class="nav-indicator special"></div>
            <div class="theFirst">功能一览</div>
            <div class="theSecond">功能一览</div>
          </router-link>
          <div class="functionBox all">
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/word.png">
              </div>
              <div class="text">
                <p>Word AI</p>
                <span>AI 智能辅写，文档创作翻倍提效</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/product.png">
              </div>
              <div class="text">
                <p>产品概述</p>
                <span>三端产品应用，满足不同工作场景需求</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/optimize.png">
              </div>
              <div class="text">
                <p>一键优化</p>
                <span>快速建立PPT统一规范，呈现专业演示</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/design.png">
              </div>
              <div class="text">
                <p>设计排版</p>
                <span>取色器、矩阵裁剪、环形布局等功能</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/tool.png">
              </div>
              <div class="text">
                <p>设计工具</p>
                <span>各种对齐排版操作，专治设计强迫症</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/resource.png">
              </div>
              <div class="text">
                <p>资源库</p>
                <span>专业团队原创设计，正版保障快速套用</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/others.png">
              </div>
              <div class="text">
                <p>其他工具</p>
                <span>PPT 拼图、PPT 瘦身等功能</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/safe.png">
              </div>
              <div class="text">
                <p>安全导出</p>
                <span>导出图片、视频、文字、只读PPT等</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/animation.png">
              </div>
              <div class="text">
                <p>动画功能</p>
                <span>补间动画、平滑过渡等功能</span>
              </div>
            </a>
          </div>
        </li>
        <li class="downloadTemp Temp"><router-link to="/DownloadPage">
            <div class="nav-indicator"></div>
            <div class="theFirst">下载</div>
            <div class="theSecond">下载</div>
          </router-link></li>
        <li class="pricingTemp Temp"><router-link to="/PricingPage">
            <div class="nav-indicator"></div>
            <div class="theFirst">定价</div>
            <div class="theSecond">定价</div>
          </router-link></li>
        <li class="corporateTemp Temp"><router-link to="/CorporateServices">
            <div class="nav-indicator special"></div>
            <div class="theFirst">企业服务</div>
            <div class="theSecond">企业服务</div>
          </router-link>
          <div class="corporateBox all">
            <div class="corporateBoxSon">
              <a href="#" class="boxA">
                <div> <img src="/images/navPhoto/api.png">
                </div>
                <div class="text">
                  <p>iSlide API</p>
                  <span>各种能力提高独立接口服务</span>
                </div>
              </a>
              <a href="#" class="boxA">
                <div> <img src="/images/navPhoto/enterprise.png">
                </div>
                <div class="text">
                  <p>企业会员</p>
                  <span>商业授权与管理协作</span>
                </div>
              </a>
              <a href="#" class="boxA">
                <div> <img src="/images/navPhoto/private.png">
                </div>
                <div class="text">
                  <p class="private">私有化部署
                    <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"
                      style="margin-left: 4px; vertical-align: 4px;">
                      <rect width="14" height="14" rx="3" fill="url(#paint0_linear_17862_6215)"></rect>
                      <path
                        d="M5.2 4.288H6.192L8.392 10H7.456L6.92 8.528H4.464L3.928 10H3L5.2 4.288ZM4.728 7.808H6.656L5.712 5.224H5.68L4.728 7.808ZM8.96663 4.288H9.83063V10H8.96663V4.288Z"
                        fill="white"></path>
                      <defs>
                        <linearGradient id="paint0_linear_17862_6215" x1="11.3974" y1="6.53277e-8" x2="-0.705625"
                          y2="7.15664" gradientUnits="userSpaceOnUse">
                          <stop stop-color="#F14DFF"></stop>
                          <stop offset="1" stop-color="#714DFF"></stop>
                        </linearGradient>
                      </defs>
                    </svg>
                  </p>
                  <span>本地部署为数据安全保驾护航</span>
                </div>
              </a>
              <a href="#" class="boxA">
                <div> <img src="/images/navPhoto/customize.png">
                </div>
                <div class="text">
                  <p>定制设计/培训</p>
                  <span>专业设计与定制培训</span>
                </div>
              </a>
              <a href="#" class="boxA">
                <div> <img src="/images/navPhoto/recommend.png">
                </div>
                <div class="text">
                  <p>向团队推荐</p>
                  <span>欢迎成为企业推荐官</span>
                </div>
              </a>
            </div>
            <span class="hasBorder"></span>
            <div class="dimensionFath">
              <div class="dimension">
                <div> <img src="/images/navPhoto/dimension.png"></div>
              </div>
              <p>扫码添加企业客服</p>
            </div>
          </div>
        </li>
        <li class="helpTemp Temp"><router-link to="/HelpSupport">
            <div class="nav-indicator special"></div>
            <div class="theFirst">帮助支持</div>
            <div class="theSecond">帮助支持</div>
          </router-link>
          <div class="helpBox all">
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/help.png">
              </div>
              <div class="text">
                <p>帮助中心</p>
                <span>使用指南、常见问题、功能教程等</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/class.png">
              </div>
              <div class="text">
                <p>牛马社课堂</p>
                <span>海量实用课程助力职场</span>
              </div>
            </a>
            <a href="#" class="boxA">
              <div> <img src="/images/navPhoto/blog.png">
              </div>
              <div class="text">
                <p>博客</p>
                <span>设计教程、PPT排版、功能技巧等</span>
              </div>
            </a>
          </div>
        </li>
      </ul>
      <div class="search">
        <img src="/images/ordinaryPicture/search.svg">
      </div>
    </div>
    <div class="diamandFath">
      <div class="buttonFather">
        <button class="promote">升级会员</button>
        <button class="login">登录注册</button>
      </div>
      <div class="diamand">
        <img src="/images/ordinaryPicture/diamond.svg">
        登录享海量资源
      </div>
    </div>
  </nav>
  <router-view></router-view>
</template>

<style scoped lang="less">
// 上方横杠
.Temp {
  position: relative;
}

.nav-indicator {
  position: absolute;
  top: 0;
  left: 15px;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background-color: rgb(248, 77, 77);
}

.special {
  left: 30px;
}

.router-link-active .nav-indicator {
  width: 30px;
}

//导航栏
.content-placeholder {
  width: 100%;
  height: 64px;
  min-width: 1300px;

}

.fixed-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background-color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

nav {
  display: flex;
  justify-content: space-between;
  width: 100%;
  height: 64px;
  align-items: center;
  position: relative;
  z-index: 100;
  background-color: #fff;
  min-width: 1300px;

  .leftPhoto {
    display: block;
    width: 110px;
    margin-left: 20px;
  }

  // 中间路由导航
  ul {
    display: flex;
    flex-wrap: nowrap;
    width: 610px;
    margin-left: 20px;

    li {
      display: block;
      //强制一行内显示
      white-space: nowrap;
      width: 130px;
      height: 44px;
      padding-top: 20px;

      a {
        display: inline;
        text-align: center;
        color: rgb(47, 47, 47);
        font-size: 15px;
        padding-left: 20px;
        padding-right: 20px;
      }
    }
  }

  .Temp {
    position: relative;

    &:hover .theFirst {
      margin-top: -20px;
      opacity: 0;
    }

    &:hover .theSecond {
      margin-top: 0;
      opacity: 1;
    }
  }

  .theFirst {
    position: absolute;
    opacity: 1;
    transition: all .3s linear;
  }

  .theSecond {
    position: absolute;
    opacity: 0;
    margin-top: 20px;
    transition: all .3s linear;
  }

  // 搜索图标
  .search {
    display: block;
    width: 23px;
    cursor: pointer;
    margin-left: 20px;
  }
}

.navCenter {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  margin-left: 80px;
}

// ppt路由
.all {
  border: 1px solid rgb(242, 243, 244);
  border-radius: 16px;
  box-shadow: 25px 25px 50px 0 rgba(0, 0, 0, .08);
  font-size: 14px;
  padding-top: 10px;
  background-color: #fff;
}

.pptTemp {
  position: relative;
  padding-right: 12px;
  margin-left: -12px;

  &:hover .PPTBox {
    display: block;
  }

  .free {
    position: absolute;
    display: block;
    top: 6px;
    left: 60px;
    width: 40px;
  }
}

// 首页
.homeTemp {
  // margin-right: -10px;
}

// ppt
.PPTBox,
.helpBox {
  position: absolute;
  z-index: 10;
  top: 63px;
  left: -20px;
  width: 400px;
  height: 260px;
  display: none;
}

// 帮助
.helpTemp {
  position: relative;

  &:hover .helpBox {
    display: block;
  }
}

// 功能
.functionTemp {
  position: relative;

  &:hover .functionBox {
    display: flex;
  }
}

.functionBox {
  position: absolute;
  z-index: 10;
  top: 63px;
  left: -380px;
  width: 1200px;
  height: 310px;
  display: flex;
  flex-wrap: wrap;
  display: none;
}

// 下载
.pricingTemp {
  margin-left: -20px;
}

// 企业
.corporateTemp {
  position: relative;
  margin-left: -20px;

  &:hover .corporateBox {
    display: flex;
  }
}

.corporateBox {
  position: absolute;
  z-index: 10;
  top: 63px;
  left: -310px;
  width: 1000px;
  height: 310px;
  display: flex;
  flex-wrap: wrap;
  display: none;
}

.corporateBoxSon {
  width: 780px;
  display: flex;
  height: 310px;
  flex-wrap: wrap;
}

.private {
  position: relative;

  svg {
    display: block;
    position: absolute;
    top: 0;
    left: 78px;
  }
}

.hasBorder {
  display: inline-block;
  height: 265px;
  margin-top: 17px;
  margin-left: -10px;
  border-left: 2px solid rgb(234, 235, 240);
}

.dimensionFath {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  width: 228px;

  p {
    margin-top: -50px;
  }
}

.dimension {
  width: 120px;
  height: 120px;
  border: 1px solid rgb(234, 235, 240);
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 70px;
  border-radius: 15px;

  img {
    width: 100px;
  }
}

// 二级导航
.boxA {
  display: flex;
  width: 320px;
  margin: 10px;
  height: 70px;
  margin-left: 20px;
  text-align: left;
  border-radius: 10px;
  align-items: center;

  &:hover {
    background-color: rgb(245, 246, 249);
  }

  .text {
    width: 100%;
    padding-left: 20px;

    p {
      width: 100%;
      height: 20px;
      font-size: 16px;
    }

    span {
      display: block;
      font-size: 14px;
      color: rgb(114, 123, 133);
      margin-top: 5px;
    }
  }

  img {
    width: 45px;
  }

}

// 右边按钮
.buttonFather {
  display: flex;
  flex-wrap: nowrap;

  button {
    width: 120px;
    height: 35px;
    font-size: 15px;
    border-radius: 5px;
  }
}

// 左边图标
.promote {
  cursor: pointer;
  background: linear-gradient(to right, rgb(248, 77, 77), rgb(255, 107, 66));
  color: #fff;
  border: 1px solid transparent;

  &:hover {
    background: linear-gradient(to right, rgb(238, 74, 74), rgb(245, 102, 64));
  }
}

.login {
  cursor: pointer;
  background-color: #fff;
  border: 1px solid rgb(231, 232, 235);
  margin-left: 20px;
  margin-right: 10px;

  &:hover {
    background-color: rgb(245, 246, 249);
  }

  img {
    width: 16px;
  }
}

.diamandFath {
  position: relative;
}

.diamand {
  position: absolute;
  top: 45px;
  right: 7px;
  font-size: 13.5px;
  width: 150px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  border-radius: 20px;
  color: rgb(169, 106, 40);
  background: linear-gradient(to right, rgb(255, 247, 176), rgb(255, 215, 137));

  &::after {
    content: "";
    width: 0;
    height: 0;
    line-height: 0;
    font-size: 0;
    border: 6px solid transparent;
    border-bottom: 6px solid rgb(255, 224, 148);
    position: absolute;
    top: -11px;
    right: 28px;
  }
}
</style>
